package cn.aicnn.chatssespringboot.persistence;

import cn.aicnn.chatssespringboot.dto.Chat;
import cn.aicnn.chatssespringboot.dto.Dialog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface chatMapper extends BaseMapper<Chat> {
    @Update("UPDATE chat SET name = #{name} WHERE id = #{chatid}")
    int updateNameByChatId(@Param("chatid") Integer chatid, @Param("name") String name);

    @Delete("DELETE FROM CHAT WHERE ID = #{chatid}")
    int deleteChat(@Param("chatid") Integer chatid);

    @Select("SELECT * FROM CHAT WHERE USER = #{name}")
    List<Chat> getList(@Param("name") String name);
}
